package main

import (
	"fmt"
)

func main() {
	ch := make(chan string)
	for i := 0; i < 5000; i++ {
		//1. go printHelloWorld(i)
		go printHelloWorldWithChan(i, ch)
	}
	//1. time.Sleep(time.Second)
	for {
		msg := <-ch
		fmt.Println(msg)
	}
}

func printHelloWorld(i int) {
	for {
		fmt.Printf("Hello world!"+
			" from groutine %d\n", i)
	}
}

func printHelloWorldWithChan(i int, ch chan string) {
	for {
		ch <- fmt.Sprintf("Hello world!"+
			" from groutine %d", i)
	}
}
